home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
X User Tools
/
X User Tools (O'Reilly and Associates)(1994).ISO
/
sources
/
xbmbrows
/
xbmbro31.z
/
xbmbro31
/
xbmbrowser3.1
/
callbacks.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-05
|
4KB
|
140 lines
/*
*****************************************************************************
** xbmbrowser version 3.1 (c) Copyright Ashley Roll, 1992.
** FILE: callbacks.c
**
** xbmbrowser is Public Domain. However it, and all the code still belong to me.
** I do, however grant permission for you to freely copy and distribute it on
** the condition that this and all other copyright notices remain unchanged in
** all distributions.
**
** This software comes with NO warranty whatsoever. I therefore take no
** responsibility for any damages, losses or problems that the program may
** cause.
*****************************************************************************
*/
#include "xbmbrowser.h"
#include "user-menu.h"
void DoQuit(w, event, params, num_params)
/* Quit the application...
** The server de-allocates all pixmaps, colors, and widgets so just exit
*/
Widget w;
XEvent *event;
String *params;
Cardinal *num_params;
{
exit(0);
}
void set_name(widget,event)
/* This function is added to the notify callback on all the
** menuButtons so that the global 'bitmap_info' contains the most
** reciently selected bitmap information line. This is then used
** in "user-menu.c" for use in user commands.
*/
Widget widget;
XButtonEvent *event;
{
XtVaGetValues( widget, XtNlabel, &bitmap_info, NULL);
XtVaSetValues( lw, XtNlabel, bitmap_info, NULL );
}
void set_label(widget, event)
/* As the pointer leaves a window -- set the label widget to point to
** file counts and/or some error string that may be preset.
*/
Widget widget;
XButtonEvent *event;
{
XtVaSetValues(lw, XtNlabel, (XtArgVal)label_info, NULL);
}
void rescan(w,client_data,call_data )
/* this is the callback for the Rescan button */
Widget w;
XtPointer client_data,call_data;
{
/* set the waitCursor */
XtVaSetValues(mainpw,XtNcursor,(XtArgVal)waitCursor,NULL);
XFlush(XtDisplay(toplevel));
rescan_bitmaps();
/* set the normal cursor */
XtVaSetValues(mainpw,XtNcursor,(XtArgVal)normalCursor,NULL);
}
void change_dir(w,client_data,call_data )
/* this is the callback for the directory name asciiTextWidget */
Widget w;
XtPointer client_data,call_data;
{
char text[2048], *diatext;
/* set the waitCursor */
XtVaSetValues(mainpw,XtNcursor,(XtArgVal)waitCursor,NULL);
XFlush(XtDisplay(toplevel));
/* get the new directory from the widget and only continue if it is
** not the same and is a VALID directory. */
diatext = XawDialogGetValueString(atw);
if(strcmp(dname,diatext) == 0) return; /* nothing to do */
strcpy(text, diatext);
/* check if the first char is '~' and substute the correct dir */
if (*text == '~') expand_tilder(text);
/* change the current directory to the new directory */
if(chdir(text) != 0) {
XtVaSetValues(atw,XtNvalue,(XtArgVal)dname,NULL);
/* set the normal cursor */
XtVaSetValues(mainpw,XtNcursor,(XtArgVal)normalCursor,NULL);
return;
}
(void) getcwd(dname,253);
XtVaSetValues(atw,XtNvalue,(XtArgVal)dname,NULL);
/* reset the bitmaps */
scan_bitmaps();
/* set the normal cursor */
XtVaSetValues(mainpw,XtNcursor,(XtArgVal)normalCursor,NULL);
}
void dir_menu(w,client_data,call_data )
/* This is the function that is used to handle the dirMenu callbacks
** it places the new directory in the text widget and calles change_dir
*/
Widget w;
XtPointer client_data,call_data;
{
XawListReturnStruct *temp;
temp = (XawListReturnStruct *) call_data;
XtVaSetValues(atw,XtNvalue,(XtArgVal)temp->string,NULL);
change_dir();
}
void pos_dir(widget,event)
/* This procedure positions the DirPopup under the cursor */
Widget widget;
XButtonEvent *event;
{
Position x,w;
XtVaGetValues(dirPopup,XtNwidth,(XtArgVal)&w,NULL);
x = event->x_root - (w/2);
XtVaSetValues(dirPopup,XtNx,(XtArgVal)x,
XtNy,(XtArgVal)event->y_root,NULL);
}